/**
 * 菜单
 */
var React = require("react");
var {Nav,NavItem} = require("react-bootstrap");
var {Util} = require("flower");
class NavIndex extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            selectKey:props.selectKey
        };
    }

    componentDidMount(){
        this.handleSelect(this.props.selectKey);
    }

    handleSelect(selectedKey) {
        if(selectedKey == "home"){
            //分类管理
            Util.goto("/load/admin/Home.jsx");
            this.setState({
                selectKey:"home"
            });
        }else if(selectedKey == "sort"){
            //分类管理
            Util.goto("/load/admin/sort/Index.jsx");
            this.setState({
                selectKey:"sort"
            });
        }else if(selectedKey == "grid"){
            //卡片管理
            Util.goto("/load/admin/grid/Index.jsx")
            this.setState({
                selectKey:"grid"
            });
        }else if(selectedKey == "tag"){
            //标签管理
            Util.goto("/load/admin/tag/Index.jsx")
            this.setState({
                selectKey:"tag"
            });
        }
    }

    render() {
        return (
            <Nav ref="mainNav" bsStyle="pills" stacked activeKey={this.state.selectKey} onSelect={this.handleSelect.bind(this)}>
                <NavItem eventKey="home">首页</NavItem>
                <NavItem eventKey="sort">分类管理</NavItem>
                <NavItem eventKey="grid">卡片管理</NavItem>
                <NavItem eventKey="tag">标签管理</NavItem>
            </Nav>
        );
    }
}
module.exports = NavIndex;